package com.dk.mydemo.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.dk.mydemo.base.ResponseEntity;
import com.dk.mydemo.modal.mybatis.Demo;
import com.dk.mydemo.service.DemoService;

@Controller
@RequestMapping(value="/demo")  
public class DemoController extends BaseController {
	
	@Autowired
	private DemoService demoService;
	
	/**
	 * 返回页面
	 * @return
	 */
	@RequestMapping(value="/save.do", method={RequestMethod.GET, RequestMethod.POST}) 
	public String testSave(){
//		for (int i = 0; i < 5; i++) {
//			Demo demo = new Demo();
//			demo.setPassword(i+"");
//			demo.setUserName("demo"+i);
//			demoService.save(demo);
//		}
		return "test";
	}
	
	/**
	 * 返回json
	 * @return
	 */
	@RequestMapping(value="/query.json", method={RequestMethod.GET, RequestMethod.POST}) 
	public ResponseEntity testQuery(){
		Demo d = demoService.queryById(2);
		//System.out.println(d.toString());
		return ResponseEntity.successResponse(d);
	}

}
